<?php session_start(); ?>
<?php ob_start(); ?>

<?php
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // Always modified
header("Cache-Control: private, no-store, no-cache, must-revalidate"); // HTTP/1.1 
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache"); // HTTP/1.0
?>
<?php include ("ewconfig.php") ?>
<?php include ("db.php") ?>
<?php include ("advsecu.php") ?>
<?php include ("phpmkrfn.php") ?>
<?php include ("ewupload.php") ?>
<?php
if (!IsLoggedIn()) {
	ob_end_clean();
	header("Location: login.php");
	exit();
}
?>



<?php require_once('Connections/MYCONN.php'); ?>
<?php

global $parentid;
global $CheckAmt;
global $CashAmt;
global $CreditAmt;
global $DepositAmt;
global $LunchAmt;
global $MetroAmt;
global $OverringAmt;
global $PayoutAmt;
global $IPPSaleAmt;
global $XReadingAmt;

if($parentid == ""){
$parentid=0;
}

function IsNull($theValue)
{
  $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;
  $theValue = ($theValue != "") ? $theValue : "";
  return trim($theValue);
}


$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}



 
mysql_select_db($database_MYCONN, $MYCONN);
if( isset($_GET["ID"]) && $_GET["ID"] != ""  )
{
$query_RecCashLog = "SELECT t.ID, u.UserName, LogDate,  r.RegisterID RegisterID, TotalIPPSales, XReading FROM tb_cashlog t, tb_users u, tb_register r WHERE  t.UserID = u.ID AND t.RegisterID = r.ID  AND t.ID = ".$_GET["ID"];
$parentid = $_GET["ID"];
}else 
{
$query_RecCashLog = "SELECT t.ID, u.UserName, LogDate,  r.RegisterID RegisterID, TotalIPPSales, XReading
FROM tb_cashlog t, tb_users u, tb_register r
WHERE t.UserID = u.ID
AND t.RegisterID = r.ID
AND t.ID = 0";
}
//echo $query_RecCashLog;
$RecCashLog = mysql_query($query_RecCashLog, $MYCONN) or die(mysql_error());
$row_RecCashLog = mysql_fetch_assoc($RecCashLog);
$totalRows_RecCashLog = mysql_num_rows($RecCashLog);


mysql_select_db($database_MYCONN, $MYCONN);
$query_RecCreditCard = "SELECT tb_creditcard.ID, tb_creditcard.CardType, tb_creditcard.Amount FROM tb_creditcard  WHERE ParentID=".$parentid;
$RecCreditCard = mysql_query($query_RecCreditCard, $MYCONN) or die(mysql_error());
$row_RecCreditCard = mysql_fetch_assoc($RecCreditCard);
$totalRows_RecCreditCard = mysql_num_rows($RecCreditCard);

mysql_select_db($database_MYCONN, $MYCONN);
$query_RecDeposits = "SELECT tb_deposits.ID, tb_deposits.Description, tb_deposits.Amount FROM tb_deposits  WHERE ParentID=".$parentid;
$RecDeposits = mysql_query($query_RecDeposits, $MYCONN) or die(mysql_error());
$row_RecDeposits = mysql_fetch_assoc($RecDeposits);
$totalRows_RecDeposits = mysql_num_rows($RecDeposits);

mysql_select_db($database_MYCONN, $MYCONN);
$query_RecLunch = "SELECT tb_lunchamt.ID, tb_lunchamt.Description, tb_lunchamt.Amount FROM tb_lunchamt WHERE ParentID=".$parentid;
$RecLunch = mysql_query($query_RecLunch, $MYCONN) or die(mysql_error());
$row_RecLunch = mysql_fetch_assoc($RecLunch);
$totalRows_RecLunch = mysql_num_rows($RecLunch);

mysql_select_db($database_MYCONN, $MYCONN);
$query_RecMetro = "SELECT tb_metrocard.ID, tb_metrocard.Description, tb_metrocard.Amount FROM tb_metrocard  WHERE ParentID=".$parentid;
$RecMetro = mysql_query($query_RecMetro, $MYCONN) or die(mysql_error());
$row_RecMetro = mysql_fetch_assoc($RecMetro);
$totalRows_RecMetro = mysql_num_rows($RecMetro);

mysql_select_db($database_MYCONN, $MYCONN);
$query_RecOverRings = "SELECT tb_overrings.ID, tb_overrings.Description, tb_overrings.Amount FROM tb_overrings WHERE ParentID=".$parentid;
$RecOverRings = mysql_query($query_RecOverRings, $MYCONN) or die(mysql_error());
$row_RecOverRings = mysql_fetch_assoc($RecOverRings);
$totalRows_RecOverRings = mysql_num_rows($RecOverRings);

mysql_select_db($database_MYCONN, $MYCONN);
$query_RecPayouts = "SELECT tb_payouts.ID, tb_payouts.Description, tb_payouts.Amount FROM tb_payouts WHERE ParentID=".$parentid;
$RecPayouts = mysql_query($query_RecPayouts, $MYCONN) or die(mysql_error());
$row_RecPayouts = mysql_fetch_assoc($RecPayouts);
$totalRows_RecPayouts = mysql_num_rows($RecPayouts);

mysql_select_db($database_MYCONN, $MYCONN);
$query_RecCash = "SELECT * FROM tb_cash WHERE ParentID=".$parentid;
$RecCash = mysql_query($query_RecCash, $MYCONN) or die(mysql_error());
$row_RecCash = mysql_fetch_assoc($RecCash);
$totalRows_RecCash = mysql_num_rows($RecCash);

mysql_select_db($database_MYCONN, $MYCONN);
$query_RecChecks = "SELECT tb_checks.ID, tb_checks.BankName, tb_checks.Amount FROM tb_checks WHERE ParentID=".$parentid;
$RecChecks = mysql_query($query_RecChecks, $MYCONN) or die(mysql_error());
$row_RecChecks = mysql_fetch_assoc($RecChecks);
$totalRows_RecChecks = mysql_num_rows($RecChecks);



function GetMultiplier($Description){ 
$return = 0;
if(strstr($Description, "$100")){
return $return = 100;
}
if(strstr($Description, "$10")){
return $return = 10;
}
if(strstr($Description, "$50")){
return $return = 50;
}
if(strstr($Description, "$20")){
return $return = 20;
}
if(strstr($Description, "$5")){
return $return = 5;
}
if(strstr($Description, "$1")){
return $return = 1;
}
if(strstr($Description, "$24")){
return $return = 24;
}
if(strstr($Description, "$7")){
return $return = 7;
}

if(strstr($Description, "$4")){
return $return = 4;
}

return $return;
}
?>

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Boca Group Pharmacy</title>
<link rel="stylesheet" type="text/css" href="report_style.css">
<style>
@page rotated {size: landscape}
.TblSubHeader1{
	border-bottom:1px solid #CCCCCC;
	border-top:1px solid #CCCCCC;
	border-right:1px solid #CCCCCC;
}
.TblSubHeader{
	border-bottom:1px solid #CCCCCC;
	border-top:1px solid #CCCCCC;
}
.RowBdr1{
	border-bottom:1px solid #CCCCCC;
	border-right:1px solid #CCCCCC;

}
.RowBdr{
	border-bottom:1px solid #CCCCCC;
}
</style>
</head>
<!--1126892761-->
<body >

<table border="0" ><tr>
<td><input type="button" onClick="javascript:window.close();" value="Close" name="BtnClose"></td>
<td><input type="button" onClick="javascript:window.print();" value="Print" name="BtnPrint"></td>
</tr></table>
<table  cellpadding="0" cellspacing="0" bordercolor="#00CCFF" id="TblCashLog"  width="500px">
  <tr >
    <td colspan="3" bgcolor="#CCCCCC" class="subHeading" style="border:1px solid  #000000; ">CASH LOG ENTRIES:</td>
  </tr>
  <tr>
      <td colspan="3" align="left" nowrap="nowrap" valign="top" style="border-bottom:1px solid  #000000; border-right:1px solid  #000000; border-left:1px solid  #000000;"><div>
	  <table cellpadding="2" >
	    <tr>
	  <td valign="top">
	  		<strong>LogDate:</strong></td>
	  		<td  valign="top" nowrap><?php echo FormatDateTime($row_RecCashLog['LogDate'],5); ?></td>
			<td valign="top"><strong>RegID:</strong></td>
	  		<td valign="top"><?php echo $row_RecCashLog['RegisterID'];?>
			</td>
					
	  		<td valign="top"><strong>User:</strong></td>
	  		<td valign="top" ><?php echo strtoupper ($row_RecCashLog['UserName']); ?></td>
			<td valign="top" nowrap="nowrap"><strong>Total IPP:</strong></td>
			<td valign="top" nowrap="nowrap" ><?php echo $row_RecCashLog['TotalIPPSales']; ?></td>
			<td  valign="top" nowrap="nowrap"><strong>X Read:</strong></td>
			<td valign="top" nowrap="nowrap" ><?php echo $row_RecCashLog['XReading']; ?></td>
</tr></table>
<?php 
$IPPSaleAmt = $row_RecCashLog['TotalIPPSales'] ;
$XReadingAmt = $row_RecCashLog['XReading'] ;
?>
				
</div></td>
</td>
  </tr>

  <tr bgcolor="#CCCCCC">
    <td colspan="3" style="border-bottom:1px solid  #000000; border-right:1px solid  #000000; border-left:1px solid  #000000;">&nbsp;</td>
  </tr>
<tr>
<td  valign="top"  align="left" class="subHeading" style="border-bottom:1px solid  #000000; border-right:1px solid  #000000; border-left:1px solid  #000000;">Add Check Amounts:
	<table cellspacing="0" cellpadding="2" width="100%">
	<tr>
		<td nowrap="nowrap" class="TblSubHeader1" ><strong>Check Description</strong></td>
		<td class="TblSubHeader"><strong>Amount</strong></td>
	</tr>

	<?php do { ?>
	<tr>
	<td class="RowBdr1"><?php echo $row_RecChecks['BankName']; ?></td>
	<td class="RowBdr"><?php echo $row_RecChecks['Amount']; ?></td>

	</tr>
	<?php $CheckAmt = $CheckAmt+$row_RecChecks['Amount']; } while ($row_RecChecks = mysql_fetch_assoc($RecChecks)); ?>
	<tr><td align="right" class="RowBdr1"><strong>Totals:</strong></td><td class="RowBdr"><strong><?php  echo $CheckAmt;?></strong></td></tr>
	</table></td>
<td valign="top"  align="left" nowrap="nowrap" class="subHeading" style="border-bottom:1px solid  #000000; border-right:1px solid  #000000; ">Add Credit Card Amounts:
	<table cellspacing="0" cellpadding="2"  width="100%">
	<tr>
	<td nowrap="nowrap" class="TblSubHeader1"><strong>Credit Card Desc</strong></td>
	<td class="TblSubHeader"><strong>Amount</strong></td>
	</tr>
	<?php do { ?>
	<tr>
	<td class="RowBdr1"><?php echo $row_RecCreditCard['CardType']; ?> </td>
	<td class="RowBdr"><?php echo $row_RecCreditCard['Amount']; ?></td>
	</tr>
	<?php $CreditAmt = $CreditAmt+$row_RecCreditCard['Amount']; } while ($row_RecCreditCard= mysql_fetch_assoc($RecCreditCard)); ?>
	<tr><td align="right" class="RowBdr1"><strong>Totals:</strong></td><td class="RowBdr"><strong><?php  echo $CreditAmt;?></strong></td></tr>
	</table>	</td>	
	<td valign="top"  align="left" class="subHeading" style="border-bottom:1px solid  #000000; border-right:1px solid  #000000;">Add Metro Amounts:
		<table cellspacing="0" cellpadding="2" width="100%">
		<tr>
		<td nowrap="nowrap" class="TblSubHeader1"><strong>Metro Card Desc</strong></td>
		<td class="TblSubHeader"><strong>Qty</strong></td>
		</tr>

		<?php do { ?>
		<tr>
		<td class="RowBdr1"><?php echo $row_RecMetro['Description']; ?></td>
		<td class="RowBdr"><?php echo $row_RecMetro['Amount']; ?></td>
		</tr>
		<?php $MetroAmt = $MetroAmt+$row_RecMetro['Amount'] * GetMultiplier($row_RecMetro['Description']);} while ($row_RecMetro= mysql_fetch_assoc($RecMetro)); ?>
					<tr><td align="right" class="RowBdr1"><strong>Totals:</strong></td><td class="RowBdr"><strong><?php  echo $MetroAmt;?></strong></td><td></td></tr>
</table>
	</td>
</tr>
<!-- SECOND ROW -->
<tr>
<td  valign="top"  align="left" class="subHeading" style="border-bottom:1px solid  #000000; border-left:1px solid  #000000; border-right:1px solid  #000000;">Add Deposit Amounts:
	<table  cellspacing="0" cellpadding="2"  width="100%">
	<tr>
	<td nowrap="nowrap" class="TblSubHeader1"><strong>Deposit Description</strong></td>
	<td class="TblSubHeader"><strong>Amount</strong></td>
	</tr>

	<?php do { ?>
	<tr>
	<td class="RowBdr1"><?php echo $row_RecDeposits['Description']; ?></td>
	<td class="RowBdr"><?php echo $row_RecDeposits['Amount']; ?></td>
	</tr>
	<?php $DepositAmt = $DepositAmt+$row_RecDeposits['Amount'] * GetMultiplier($row_RecDeposits['Description']);} while ($row_RecDeposits = mysql_fetch_assoc($RecDeposits)); ?>
<tr><td align="right" class="RowBdr1"><strong>Totals:</strong></td><td class="RowBdr"><strong><?php  echo $DepositAmt;?></strong></td></tr>
	</table></td>
<td valign="top"  align="left" nowrap="nowrap" class="subHeading" style="border-bottom:1px solid  #000000; border-right:1px solid  #000000;">Add Lunch Amounts:
	<table  cellspacing="0" cellpadding="2"  width="100%">
	<tr>
	<td class="TblSubHeader1"><strong>Lunch Desc</strong></td>
	<td class="TblSubHeader"><strong>Amount</strong></td>
	</tr>
	<?php do { ?>
	<tr>
	<td class="RowBdr1"><?php echo $row_RecLunch['Description']; ?></td>
	<td class="RowBdr"><?php echo $row_RecLunch['Amount']; ?></td>
	</tr>
	<?php $LunchAmt = $LunchAmt+$row_RecLunch['Amount'];
} while ($row_RecLunch= mysql_fetch_assoc($RecLunch)); ?>
<tr><td align="right" class="RowBdr1"><strong>Totals:</strong></td><td class="RowBdr"><strong><?php  echo $LunchAmt;?></strong></td></tr>
	</table></td>	
<td valign="top"  align="left" class="subHeading" style="border-bottom:1px solid  #000000; border-right:1px solid  #000000;">Add Overring Amounts:
	<table  cellspacing="0" cellpadding="2"  width="100%">
	<tr>
	<td class="TblSubHeader1"><strong>Description</strong></td>
	<td class="TblSubHeader"><strong>Amount</strong></td>
	</tr>
	<?php do { ?>
	<tr>
	<td class="RowBdr1"><?php echo $row_RecOverRings['Description']; ?></td>
	<td class="RowBdr"><?php echo $row_RecOverRings['Amount']; ?></td>
	</tr>
	<?php $OverringAmt = $OverringAmt+$row_RecOverRings['Amount'] ;}while ($row_RecOverRings= mysql_fetch_assoc($RecOverRings)); ?>
	<tr><td align="right" class="RowBdr1"><strong>Totals:</strong></td><td class="RowBdr"><strong><?php  echo $OverringAmt;?></strong></td></tr>
	</table></td>
</tr>
<tr>
<td colspan="2"  align="left" valign="top" class="subHeading" style="border-bottom:1px solid  #000000; border-left:1px solid  #000000; border-right:1px solid  #000000;">Add Cash and Coins Amounts:
	<table cellspacing="0" cellpadding="2"  width="100%" >
	<tr>
	<td class="TblSubHeader1"><strong>Hndrds</strong></td>
	<td class="TblSubHeader1"><strong>Ffts</strong></td>
	<td class="TblSubHeader1"><strong>Twnts</strong></td>
	<td class="TblSubHeader1"><strong>Tns</strong></td>
	<td class="TblSubHeader1"><strong>Fvs</strong></td>
	<td class="TblSubHeader1"><strong>Sngls</strong></td>
	<td class="TblSubHeader1"><strong>Qrtrs</strong></td>
	<td class="TblSubHeader1"><strong>Dms</strong></td>
	<td class="TblSubHeader1"><strong>Nckls</strong></td>
	<td class="TblSubHeader1"><strong>Pnns</strong></td>
	<td class="TblSubHeader1"><strong>Dllrs</strong></td>
	<td class="TblSubHeader"><strong>1/2Dllrs</strong></td>
	<td class="TblSubHeader"><strong>Roll Qrtr</strong></td>
	<td class="TblSubHeader"><strong>Roll Dm</strong></td>
	<td class="TblSubHeader"><strong>Roll Nckle</strong></td>
	<td class="TblSubHeader"><strong>Roll Pnn</strong></td>

 	</tr>

	<?php do { ?>
	<tr>
		<td class="RowBdr1"><?php echo $row_RecCash['Cash_Hundred']; ?></td>
		<td class="RowBdr1"><?php echo $row_RecCash['Cash_Fifty']; ?></td>
		<td class="RowBdr1"><?php echo $row_RecCash['Cash_twenty']; ?></td>
		<td class="RowBdr1"><?php echo $row_RecCash['Cash_Ten']; ?></td>
		<td class="RowBdr1"><?php echo $row_RecCash['Cash_five']; ?></td>
		<td class="RowBdr1"><?php echo $row_RecCash['Cash_single']; ?></td>
		<td class="RowBdr1"><?php echo $row_RecCash['Coin_Quarter']; ?></td>
		<td class="RowBdr1"><?php echo $row_RecCash['Coin_Dime']; ?></td>
		<td class="RowBdr1"><?php echo $row_RecCash['Coin_Nickle']; ?></td>
		<td class="RowBdr1"><?php echo $row_RecCash['Coin_Penny']; ?></td>
		<td class="RowBdr1"><?php echo $row_RecCash['Coin_Dollar']; ?></td>
		<td class="RowBdr"><?php echo $row_RecCash['Coin_Halfdollar']; ?></td>
		<td class="RowBdr"><?php echo $row_RecCash['Roll_Quarter']; ?></td>
		<td class="RowBdr"><?php echo $row_RecCash['Roll_Dime']; ?></td>
		<td class="RowBdr"><?php echo $row_RecCash['Roll_Nickle']; ?></td>
		<td class="RowBdr"><?php echo $row_RecCash['Roll_Penny']; ?></td>

	</tr>
	<?php $CashAmt = $CashAmt + 100*$row_RecCash['Cash_Hundred']+
								50*$row_RecCash['Cash_Fifty']+
								20*$row_RecCash['Cash_twenty']+
								10*$row_RecCash['Cash_Ten']+
								5*$row_RecCash['Cash_five']+
								1*$row_RecCash['Cash_single']+
								0.25*$row_RecCash['Coin_Quarter']+
								0.10*$row_RecCash['Coin_Dime']+
								0.05*$row_RecCash['Coin_Nickle']+
								0.01*$row_RecCash['Coin_Penny']+
								10.00*$row_RecCash['Roll_Quarter']+
								5.00*$row_RecCash['Roll_Dime']+
								2.00*$row_RecCash['Roll_Nickle']+
								0.50*$row_RecCash['Roll_Penny']+
								1*$row_RecCash['Coin_Dollar']+
								0.50*$row_RecCash['Coin_Halfdollar'];
} while ($row_RecCash= mysql_fetch_assoc($RecCash)); ?>
	
<tr>

<td valign="top" colspan="11" align="right" class="RowBdr1"><strong>Totals:</strong></td>
<td valign="top" class="RowBdr"><strong><?php echo $CashAmt; ?></strong></td>
</tr>
	</table></td>
<td valign="top" align="left" class="subHeading" style="border-bottom:1px solid  #000000; border-right:1px solid  #000000;">Add Payout Amounts:
	<table   cellspacing="0" cellpadding="2"  width="100%">
	<tr>
	<td class="TblSubHeader1"><strong>Pay Description</strong></td>
	<td class="TblSubHeader"><strong>Amount</strong></td>
	</tr>

	<?php do { ?>
	<tr>
	<td class="RowBdr1"><?php echo $row_RecPayouts['Description']; ?></td>
	<td class="RowBdr"><?php echo $row_RecPayouts['Amount']; ?></td>
	</tr>
	<?php $PayoutAmt = $PayoutAmt+$row_RecPayouts['Amount'] ;} while ($row_RecPayouts= mysql_fetch_assoc($RecPayouts)); ?>
		<tr><td align="right" class="RowBdr1"><strong>Totals:</strong></td><td class="RowBdr"><strong><?php  echo $PayoutAmt;?></strong></td></tr>
	</table></td>
</tr>
<tr>
<td class="subHeading">GRAND TOTALS : <?php
echo $CheckAmt+$CashAmt+$CreditAmt+$DepositAmt+$LunchAmt+$MetroAmt+$OverringAmt+$PayoutAmt+$IPPSaleAmt+$XReadingAmt;
?></td>
<td colspan="2" class="subHeading">&nbsp;
</td></tr>
</table>


</body>
</html>

<?php
mysql_free_result($RecCashLog);
mysql_free_result($RecCreditCard);
mysql_free_result($RecDeposits);
mysql_free_result($RecLunch);
mysql_free_result($RecMetro);
mysql_free_result($RecOverRings);
mysql_free_result($RecPayouts);
mysql_free_result($RecCash);
mysql_free_result($RecChecks);
?>
